﻿namespace NEvoWeb.Modules.NB_Store
{
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections.Specialized;
    using System.Runtime.CompilerServices;
    using System.Web;
    using System.Web.UI.WebControls;

    public class RemotePost : BaseModule
    {
        [AccessedThroughProperty("plhMsg")]
        private PlaceHolder _plhMsg;
        public string FormName;
        private NameValueCollection Inputs;
        public string Method;
        public string Url;

        public RemotePost()
        {
            base.Load += new EventHandler(this.Page_Load);
            this.Inputs = new NameValueCollection();
            this.Url = "";
            this.Method = "post";
            this.FormName = "form";
        }

        public void Add(string name, string value)
        {
            this.Inputs.Add(name, value);
        }

        public string GetPostHtml(string LoadingImageURL)
        {
            int num=0;
            string str2 = "";
            str2 = "<html><head>";
            str2 = str2 + "</head><body onload=\"document." + this.FormName + ".submit()\">";
            str2 = str2 + "<form name=\"" + this.FormName + "\" method=\"" + this.Method + "\" action=\"" + this.Url + "\">";
            int num3 = num + 1;
            int num2 = this.Inputs.Keys.Count - 1;
            for (num = 0; ((num3 >> 0x1f) ^ num) <= ((num3 >> 0x1f) ^ num2); num += num3)
            {
                str2 = str2 + "<input type=\"hidden\" name=\"" + this.Inputs.Keys[num] + "\" value=\"" + this.Inputs[this.Inputs.Keys[num]] + "\" />";
            }
            return ((((((str2 + "</form>") + "  <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" height=\"100%\">" + "<tr><td width=\"100%\" height=\"100%\" valign=\"middle\" align=\"center\">") + "<font style=\"font-family: Trebuchet MS, Verdana, Helvetica;font-size: 14px;letter-spacing: 1px;font-weight: bold;\">" + "Processing...") + "</font><br /><br /><img src=\"" + LoadingImageURL + "\" />     ") + "</td></tr>") + "</table>" + "</body></html>");
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            NB_Store_CartInfo currentCart = CurrentCart.GetCurrentCart(this.PortalId);
            if (currentCart.BankTransID != currentCart.OrderID)
            {
                currentCart.BankTransID = currentCart.OrderID;
                string s = "";
                s = CurrentCart.GetCurrentCart(this.PortalId).BankHtmlRedirect;
                if (s == "")
                {
                    s = Conversions.ToString(this.Session["BankHtmlRedirect"]);
                    this.Session["BankHtmlRedirect"] = "";
                }
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.Write(s);
                HttpContext.Current.Response.End();
            }
            else
            {
                SharedFunctions.DisplayMsgText(Conversions.ToString(this.PortalId), this.plhMsg, "paymentinprocess.text", "Payment already being processed!!");
            }
        }

        protected virtual PlaceHolder plhMsg
        {
            get
            {
                return this._plhMsg;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._plhMsg = value;
            }
        }
    }
}

